<template>
    <div>
      <h1>会员信息录入</h1>
     <a href="/show">查看会员信息</a>
      <table class="table">
        <tbody> 
            <tr>
                <td>姓名</td>
                <td><input type="text" v-model="data.name"></td>
            </tr>
            <tr>
                <td>电话</td>
                <td><input type="text" v-model="data.phone"></td>
            </tr>
            <tr>
                <td>邮箱</td>
                <td><input type="text" v-model="data.youxiang"></td>
            </tr>
            <tr>
                <td>头像</td>
                <td><input type="text" v-model="data.img"></td>
            </tr>
            <tr>
                <td>状态</td>
                <td>
                    <input type="checkbox" checked v-model="data.state">选中为启用,未选中为禁用
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td>
                    <input type="radio" v-model="data.sex" value="1" name="sex" checked>男
                    <input type="radio"v-model="data.sex" value="2" name="sex" >女
                </td>
            </tr>
            <tr>
                <td>年龄</td>
                <td><input type="text" v-model="data.age"></td>
            </tr>
            <tr>
                <td colspan="2"><input type="button" value="添加" @click="add"></td>
            </tr>
        </tbody>
      </table> 
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'

const router=useRouter();

const data=ref({
  "id": 0,
  "name": "",
  "phone": "",
  "youxiang": "",
  "img": "",
  "state": true,
  "sex": 0,
  "age": 0,
  "dateMember": "2025-04-23T01:42:41.397Z",
  "isDelete": true
})

const add=()=>{
    axios.post("https://localhost:7175/api/Member/AddMember",data.value).then(res=>{
         if(res.data>0)
         {
           alert("添加成功")
           router.push({path:"/show"})
         }
         else{
            alert("添加失败")
            return;
         }
    })
}


</script>

<style scoped>

</style>